package com.yenlien.traceyun.business.entity;

import com.yenlien.traceyun.business.service.RecallData;
import com.yenlien.traceyun.business.trace.Trace;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created by LiuSha on 2020/7/28.
 * 仓储管理
 */
@Entity
@Table(name = "t_storage_manage")
@Trace(stepName = "storageManage", order = 1, branch = "purchase")
public class StorageManage extends TraceScanEntity implements RecallData {


    private String payState; //付款状态  0=未付款 1=已付款 2=尾款
    private String contractPdf;   // 合同pdf
    private String money;   // 金额

    @Column(name = "warehouse_id", length = 32)
    private String warehouseId;//仓库Id
    @Column(name = "warehouse_part_id", length = 32)
    private String warehousePartId;//仓位
    @Column(name = "warehouse_part_name")
    private String warehousePartName;//仓位名

    @Column(name = "warehouseName")
    private String warehouseName;//仓库名
    /**
     * 入库类型，0采购入库，1分包入库
     */
    @Column(name = "in_type", length = 1)
    private String inType;
    /**
     * 供应商名称
     */
    @Column(name = "supplier_name", length = 50)
    private String supplierName;


    private String cop; // 成品/半成品/原料/辅料

    private String materialCode;    // 物理代码

    /**
     * //入库批次
     */
    @Column(name = "batch", length = 30)
    private String batch;

    /**
     * 关联id,分包id,采购id
     */
    @Column(name = "relate_id", length = 32)
    private String relateId;

    /**
     * 来源批次
     */
    @Column(name = "source_batch", length = 30)
    private String sourceBatch;

    /**
     * 采购员
     */
    @Column(name = "buyer", length = 10)
    private String buyer;
    /**
     * 入库时间
     */
    @Column
    private Date inTime;

    /**
     * 采购入库类型（0溯源或1非溯源）
     */
    @Column(name = "purchase_type", length = 1)
    private String purchaseType;
    private String sourceCode;  // 溯源入库时的追溯码

    /**
     * 产品名称
     */
    @Column(name = "product_name", length = 50)
    private String productName;

    /**
     * 规格数量
     */
    @Column(name = "specs", length = 10)
    private BigDecimal specs;

    /**
     * 数量
     */
    @Column(name = "number", length = 8)
    private BigDecimal number;

    /**
     * 库存数量
     */
    @Column(name = "surplus", length = 8)
    private BigDecimal surplus;

    /**
     * 生产企业
     */
    @Column(name = "manufacturer", length = 50)
    private String manufacturer;

    /**
     * 产地
     */
    @Column(name = "place", length = 50)
    private String place;

    /**
     * 需要出库数量的数量
     */
    @Column(name = "out_num", length = 4)
    private int outNum;

    /**
     * 是否检测  0=未检测 1=已检查
     */
    @Column(name = "is_check", length = 1)
    private int isCheck;

    /**
     * 规格
     */
    @Column(name = "specs_unit", length = 10)
    private String specsUnit;

    /**
     * 物料类型
     */
    @Column(name = "materialType", length = 50)
    private String materialType;

    /**
     * appid
     */
    @Column(name = "app_id", length = 20)
    private String appId;

    public String getMaterialCode() {
        return materialCode;
    }

    public void setMaterialCode(String materialCode) {
        this.materialCode = materialCode;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public String getCop() {
        return cop;
    }

    public void setCop(String cop) {
        this.cop = cop;
    }

    @Transient
    private List<StorageManageDetailed> storageManageDetaileds;//明细
    @Transient
    private List<StorageManageCuring> storageManageCuringList;//养护

    public String getMaterialType() {
        return materialType;
    }

    public void setMaterialType(String materialType) {
        this.materialType = materialType;
    }

    public StorageManageDetailed getDetail() {
        StorageManageDetailed detailed = new StorageManageDetailed();
        detailed.setCreatetime(new Date());
        detailed.setLastStep(this.getId());
        detailed.setStorageManageId(this.getId());
        detailed.setSpecs(this.getSpecs());
        detailed.setSpecsUnit(this.getSpecsUnit());
        return detailed;
    }

    public String getSourceCode() {
        return sourceCode;
    }

    public void setSourceCode(String sourceCode) {
        this.sourceCode = sourceCode;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public String getPayState() {
        return payState;
    }

    public void setPayState(String payState) {
        this.payState = payState;
    }

    public String getContractPdf() {
        return contractPdf;
    }

    public void setContractPdf(String contractPdf) {
        this.contractPdf = contractPdf;
    }

    public String getSourceBatch() {
        return sourceBatch;
    }

    public void setSourceBatch(String sourceBatch) {
        this.sourceBatch = sourceBatch;
    }

    public int getOutNum() {
        return outNum;
    }

    public void setOutNum(int outNum) {
        this.outNum = outNum;
    }

    public List<StorageManageCuring> getStorageManageCuringList() {
        return storageManageCuringList;
    }

    public void setStorageManageCuringList(List<StorageManageCuring> storageManageCuringList) {
        this.storageManageCuringList = storageManageCuringList;
    }

    public List<StorageManageDetailed> getStorageManageDetaileds() {
        return storageManageDetaileds;
    }

    public void setStorageManageDetaileds(List<StorageManageDetailed> storageManageDetaileds) {
        this.storageManageDetaileds = storageManageDetaileds;
    }

    public BigDecimal getSurplus() {
        return surplus;
    }

    public void setSurplus(BigDecimal surplus) {
        this.surplus = surplus;
    }

    public String getWarehouseId() {
        return warehouseId;
    }

    public void setWarehouseId(String warehouseId) {
        this.warehouseId = warehouseId;
    }

    public String getWarehousePartId() {
        return warehousePartId;
    }

    public void setWarehousePartId(String warehousePartId) {
        this.warehousePartId = warehousePartId;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public String getBatch() {
        return batch;
    }

    public void setBatch(String batch) {
        this.batch = batch;
    }

    public String getBuyer() {
        return buyer;
    }

    public void setBuyer(String buyer) {
        this.buyer = buyer;
    }

    public Date getInTime() {
        return inTime;
    }

    public void setInTime(Date inTime) {
        this.inTime = inTime;
    }


    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public BigDecimal getSpecs() {
        return specs;
    }

    public void setSpecs(BigDecimal specs) {
        this.specs = specs;
    }

    public BigDecimal getNumber() {
        return number;
    }

    public void setNumber(BigDecimal number) {
        this.number = number;
    }


    public int getIsCheck() {
        return isCheck;
    }

    public void setIsCheck(int isCheck) {
        this.isCheck = isCheck;
    }

    public String getRelateId() {
        return relateId;
    }

    public void setRelateId(String relateId) {
        this.relateId = relateId;
    }

    @Override
    public String getRecallName() {
        return this.productName;
    }

    @Override
    public String getRecallSpec() {
        if (specs != null) {
            return specs.toString() + specsUnit;
        } else {
            return specsUnit;
        }

    }

    @Override
    public String getRecallNum() {
        return number.toString();
    }

    public String getWarehousePartName() {
        return warehousePartName;
    }

    public void setWarehousePartName(String warehousePartName) {
        this.warehousePartName = warehousePartName;
    }

    public String getPurchaseType() {
        return purchaseType;
    }

    public void setPurchaseType(String purchaseType) {
        this.purchaseType = purchaseType;
    }

    public String getInType() {
        return inType;
    }

    public void setInType(String inType) {
        this.inType = inType;
    }

    public String getSpecsUnit() {
        return specsUnit;
    }

    public void setSpecsUnit(String specsUnit) {
        this.specsUnit = specsUnit;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }
}
